﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZEBuz.Questionnaire.Lib.Util;
using System.Data;
using System.Text;
using ZEBuz.Questionnaire.Lib.Entities;

namespace ZEBuz.Questionnaire.Web.Admin
{
    public partial class view : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //FillData();
        }

        //private void FillData()
        //{
        //    QuestionnaireUser qu = new QuestionnaireUser().Get(Request.QueryString["seqno"].ToInt());
        //    lblTitle.Text = qu.Questionnaire.QuestionnaireDTO.name;

        //    //全部写在这儿，构建HTML
        //    StringBuilder sb = new StringBuilder();
        //    XMLQuestionnaire qn = qu.Questionnaire.QuestionnaireDTO;
        //    int i = 0;
        //    foreach (var q in qn.questions)
        //    {
        //        var cssname = (i % 2 == 0) ? "" : "class='alternateline'";
        //        if (qu.UserAnswers.Find(a => a.XMLQuestionId == q.id) != null)
        //        {
        //            var opt = qn.options.Find(o => o.id == (qu.UserAnswers.Find(a => a.XMLQuestionId == q.id).XMLOptionId));
        //            if (opt != null)
        //                sb.AppendFormat("<tr {0}><td>{3}</td><td>{1}</td><td>{2}</td>", cssname, q.content, opt.content, q.id);
        //        }
        //        else
        //        {
        //            sb.AppendFormat("<tr {0}><td>{2}</td><td>{1}</td><td class='error'>未选择或无法正确提取</td>", cssname, q.content, q.id);
        //        }
        //        i++;
        //    }

        //    this.lblQuestionnaire.Text = sb.ToString();

        //    QuestionnaireUserReport rpt = new QuestionnaireUserReport(qu.UserAnswerString, 1/*qu.QuestionnaireId*/);

        //    // 拿到REPORT对象后，开始写页面
        //    StringBuilder sb2 = new StringBuilder();
        //    foreach (var o in rpt.Categories)
        //    {
        //        var lvl = o.Category.levels.Find(l => l.max >= o.TotalPoint && l.min <= o.TotalPoint);
        //        sb2.AppendFormat("分类：{0} <br/>您的分数{1} <br/>平均分{2} <br/>分值处于：{3} {4}<br/><br/>",
        //            o.Category.name,
        //            o.TotalPoint,
        //            o.Average,
        //            lvl != null ? lvl.name : string.Empty,
        //            lvl != null ? lvl.text : string.Empty
        //            );
        //    }

        //    this.lbl.Text = sb2.ToString();
        //}
    }
}